import Vue from 'vue';
import tpl from './tpl.html';
import './style.scss';
import Loading from '../../../../../grsc-base/component/Loading.vue';
import service from './service';
import lib from '../../../../common/lib';
import NoData from '../../../../../grsc-base/component/NoData.vue';
import detailed from './detailed/main';
export default Vue.extend({
  name: "teamAdmin",
  template: tpl,
  components: {
    Loading,
    NoData,
    detailed
  },
  data(){
    return{
      lib,
      isLoading:false,
      isBingDing:false,
      isLoadings:false,
      list:[],
      uid:'',
      item:'',
      reason:'',
      isShow:false,
    }
  },
  mounted(){
    this.getUserBindStatus()
  },
  methods:{
    //查看詳情
    detailed(item){
      this.item = item;
      this.isShow = true;
    },
    //隱藏
    hide(){
      this.isShow = false;
    },
    //添加下级
    addSubordinate(){
      if(!this.uid){
        window.error(this.$t('teamAdmian.uidTip'))
        return;
      }
      if(!this.reason){
        window.error(this.$t('teamAdmian.reason'))
        return;
      }
      this.isBingDing = true;
      service.userApplyPointLower({pUid:this.uid,applyInfo:this.reason}).done(data=>{
        this.isBingDing = false;
        if(data.code == window.CODE.SUCCESS){
          window.success(this.$t('teamAdmian.success'))
          this.getUserBindStatus();
          this.uid = '';
          this.reason = '';
        }else{
          window.error(data.msg)
        }
      })
    },
    //通知颜色
    actives(obj){
      return obj == 'BIND_SUCCESS'? 'success' : obj == 'BIND_FAIL' ? 'error' : '';
    },
    //查询绑定的用户
    getUserBindStatus(){
      this.isLoadings = true;
      this.isLoading = true;
      service.getUserBindStatus().done(data=>{
        // console.log('外面',data)
        this.isLoadings = false;
        this.isLoading = false;
        if(data.code == window.CODE.SUCCESS){ 
          this.list = data.data;
        }else{
          window.error(data.msg)
        }
      })
    }
  }
})